package org.mock.controller;

import lombok.AllArgsConstructor;
import org.mock.request.baiFenHui.*;
import org.mock.common.ResultBaiFenHui;
import org.mock.service.BaifenhuiNoticeService;
import org.mock.service.BaifenhuiOrderBaseService;
import org.mock.service.BaifenhuiProductService;
import org.springframework.web.bind.annotation.*;

/**
 * baiFenHui mock
 *
 * @author AI
 * @since 2020-06-19
 */
@RestController
@AllArgsConstructor
@RequestMapping("baiFenHui")
public class BaiFenHuiMockController {

    private BaifenhuiProductService baifenhuiProductService;
    private BaifenhuiNoticeService baifenhuiNoticeService;
    private BaifenhuiOrderBaseService baifenhuiOrderBaseService;

    /**
     * 获取token
     * @return
     */
    @PostMapping("/Index/getToken")
    public String getToken(@RequestBody TokenRequest request) {
        return "{\n" +
                "    \"result\": true,\n" +
                "    \"errCode\": \"0000\",\n" +
                "    \"desc\": \"success\",\n" +
                "    \"data\": {\n" +
                "        \"token\": \"68baa8c4ac4936f37cb2a9bc03ac82ad\",\n" +
                "        \"deadline\": \"2021-05-26 09:08:16\"\n" +
                "    }\n" +
                "}";
    }

    /**
     * 查询消息
     * @return
     */
    @PostMapping("/Notic/getNotics")
    public ResultBaiFenHui getNotics(@RequestBody GetNoticeRequest request) {
        return baifenhuiNoticeService.getNotice(request);
    }

    /**
     * 消费消息
     * @return
     */
    @PostMapping("/Notic/doNotics")
    public ResultBaiFenHui doNotics(@RequestBody DoNoticeRequest request) {
        return baifenhuiNoticeService.doNotice(request);
    }

    /**
     * 查询商品详情
     * @return
     */
    @PostMapping("/Product/getGoodInfo")
    public ResultBaiFenHui getGoodInfo(@RequestBody GoodInfoRequest request) {
        return baifenhuiProductService.getGoodInfo(request);
    }

    /**
     * 直充订单创建
     * @return
     */
    @PostMapping("/Order/createRechargeOrder")
    public ResultBaiFenHui createRechargeOrder(@RequestBody CreateRechargeOrderRequest request) {
        return baifenhuiProductService.createRechargeOrder(request);
    }

    /**
     * 订单详情统一查询（百分汇的订单号）
     * @return
     */
    @PostMapping("/Order/getOrderInfo")
    public ResultBaiFenHui getOrderInfo(@RequestBody OrderInfoRequest request) {
        return baifenhuiOrderBaseService.getOrderInfo(request);
    }

    /**
     * 反查订单详情（客户单号）
     * @return
     */
    @PostMapping("/Order/getOrderInfoByCustomer")
    public ResultBaiFenHui getOrderInfoByCustomer(@RequestBody OrderInfoByCustomerRequest request) {
        return baifenhuiOrderBaseService.getOrderInfoByCustomer(request);
    }

    /**
     * 出库（百分汇没有该接口，内部自测用）
     * @param orderId
     * @return
     */
    @GetMapping("/Order/finish")
    public ResultBaiFenHui orderFinish(String orderId) {
        return baifenhuiOrderBaseService.orderFinish(orderId);
    }
}